package org.raymond.iworks.study.netty.atguigu.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;
import lombok.extern.slf4j.Slf4j;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
@Slf4j
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        log.info("initChannel...");
        ch.pipeline()
                .addLast("httpCodec", new HttpServerCodec())
                .addLast("testHttpHandler", new TestServerHandler())
                .addLast("1", new DisplayInboundHandler())
                .addLast("2", new DisplayInboundHandler())
                .addLast("3", new DisplayInboundHandler())
                .addLast("4", new DisplayOutboundHandler())
                .addLast("5", new DisplayOutboundHandler())
                .addLast("6", new DisplayOutboundHandler())
        ;
    }

    // inbound:1->2->3 outbound:6->5->4
    // inbound: handlerAdded->
    //   channelRegistered->channelActive->channelRead->channelReadComplete->channelInactive->channelUnregistered
    // outbound: handlerAdded-> read->read->read->read->read->read
}
